var n = require;
var o = module;
cc.Class({
    extends: cc.Component,
    properties: {wordRoot: cc.Node, prefabWord: cc.Prefab, quanXuan: cc.Animation, findTag: cc.Label},
    onLoad: function onLoad() {},
    start: function start() {
        var n = this;
        (this.level = lGlobal.curLevel),
            (this.winLabel = lGlobal.lvCfg.json[lGlobal.curModel][lGlobal.curLevel].winLabel),
            (this.proLabel = lGlobal.lvCfg.json[lGlobal.curModel][lGlobal.curLevel].proLabel),
            (this.proCount = 81),
            this.node.on("WordOnTouchStart", this.onWordOnTouchStart.bind(this)),
            (this.winLabMakeInd = Math.floor(Math.random() * this.proCount));
        for (
            var o = function o(_o) {
                    setTimeout(function () {
                        var t = cc.instantiate(n.prefabWord);
                        t.parent = n.wordRoot;
                        var e = t.getComponent("Word");
                        _o == n.winLabMakeInd
                            ? (e.setLabel(n.winLabel), (n.findTag.string = "找到：" + n.winLabel))
                            : e.setLabel(n.proLabel);
                    }, 10 * _o);
                },
                t = 0;
            t < this.proCount;
            t++
        ) {
            o(t);
        }
    },
    onWordOnTouchStart: function onWordOnTouchStart(n) {
        var o = this,
            t = n.getUserData();
        t.label == this.winLabel
            ? (this.quanXuan.play("quanxuangou"), soundMgr.playSound(soundMgr.right))
            : (this.quanXuan.play("quanxuancha"), soundMgr.playSound(soundMgr.wrong)),
            (this.quanXuan.node.position = t.node.position),
            (this.quanXuan.node.active = !0),
            this.quanXuan.on("finished", function () {
                o.quanXuan.off("finished"),
                    t.label == o.winLabel
                        ? window.ui.win({model: "WordFind", lv: o.level, label: t.label})
                        : (o.quanXuan.node.active = !1);
            });
    },
    randPosition: function randPosition(n, o, t, e) {
        var r = cc.v2(0, 0);
        return (r.x = t + Math.random() * n), (r.y = e + Math.random() * o), r;
    }
});
